<?php session_start();
require_once('functions.php');
connectlogin();
if(isset($_SESSION['username'])){

	function check_login($level) {
					
		$username_s = mysql_real_escape_string($_SESSION['username']); 
		
		$sql = "SELECT * FROM account_data WHERE name = '$username_s'"; 
		$result = mysql_query($sql);
		$row = mysql_fetch_array($result);
		
		$user_level = $row['access_level'];
		$restricted = $row['membership'];
		
		//$sql = "SELECT level_disabled FROM login_levels WHERE level_level = '$user_level'"; 
		//$result = mysql_query($sql);
		//$row2 = mysql_fetch_array($result);
		
		$disabled = $row['activated'];
		
		if($disabled != 1) { include('disabled.php'); exit();
			
		} elseif($restricted != 0) { include('disabled.php'); exit();
			
		} elseif($user_level >= $level) { // User has authority to view this page.		
		
		} else { include('user_level.php'); exit();
		
		}
	
	}

} else {

	function check_login($level) { exit(); }

include('/includes/login.inc.php'); 
exit();	
} ?>